package cn.iocoder.yudao.module.crossborder.platform.api;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.crossborder.platform.api.dto.PlatformConfigDTO;
import cn.iocoder.yudao.module.crossborder.platform.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 平台同步 API 接口
 *
 * @author LHL
 */
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿：fallbackFactory =
@Tag(name = "RPC 服务 - 平台同步")
public interface PlatformSyncApi {

    String PREFIX = ApiConstants.PREFIX + "/sync";

    @GetMapping(PREFIX + "/get-platform-config")
    @Operation(summary = "获得平台配置")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    CommonResult<PlatformConfigDTO> getPlatformConfig(@RequestParam("id") @NotNull Long id);

    @GetMapping(PREFIX + "/list-platform-configs")
    @Operation(summary = "获得平台配置列表")
    @Parameter(name = "platformType", description = "平台类型", example = "AMAZON")
    CommonResult<List<PlatformConfigDTO>> listPlatformConfigs(@RequestParam(value = "platformType", required = false) String platformType);

    @PostMapping(PREFIX + "/sync-products")
    @Operation(summary = "同步商品到平台")
    @Parameter(name = "platformId", description = "平台编号", required = true, example = "1024")
    @Parameter(name = "productIds", description = "商品编号列表", required = true)
    CommonResult<Boolean> syncProducts(@RequestParam("platformId") @NotNull Long platformId,
                                       @RequestParam("productIds") @NotNull List<Long> productIds);

    @PostMapping(PREFIX + "/sync-orders")
    @Operation(summary = "同步订单从平台")
    @Parameter(name = "platformId", description = "平台编号", required = true, example = "1024")
    CommonResult<Boolean> syncOrders(@RequestParam("platformId") @NotNull Long platformId);

    @PostMapping(PREFIX + "/sync-inventory")
    @Operation(summary = "同步库存到平台")
    @Parameter(name = "platformId", description = "平台编号", required = true, example = "1024")
    @Parameter(name = "productIds", description = "商品编号列表", required = true)
    CommonResult<Boolean> syncInventory(@RequestParam("platformId") @NotNull Long platformId,
                                        @RequestParam("productIds") @NotNull List<Long> productIds);

}
